<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('文档到期提醒列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                        	<li>
                                <label>档案编号：</label>
                                <input type="text" name="code"/>
                            </li>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="toolsType" th:with="type=${@dict.getType('gcgl_wdtype')}">
                                	<option value="">----所有----</option>
					                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					            </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="gcgl:wddqtx:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                 <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="gcgl:wddqtx:edit"> -->
<!--                     <i class="fa fa-edit"></i> 修改 -->
<!--                 </a> -->
<!--                 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="gcgl:wddqtx:remove"> -->
<!--                     <i class="fa fa-remove"></i> 删除 -->
<!--                 </a> -->
<!--                 <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gcgl:wddqtx:export"> -->
<!--                     <i class="fa fa-download"></i> 导出 -->
<!--                 </a> -->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:wddqtx:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:wddqtx:remove')}]];
        var datas = [[${@dict.getType('gcgl_wdtype')}]];
        var prefix = ctx + "gcgl/wddqtx";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "文档到期提醒",
                sortName: "id desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'code',
                    title: '档案编号'
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'toolsType',
                    title: '类型',
                    formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.toolsType);
		            }
                },
                {
                    field: 'yxqz',
                    title: '有效期至',
                    cellStyle: function(value, row, index) {
                        var date = new Date();//当前时间
                        var yxq = new Date(row.yxqz);//有效期至
                        yxq.setDate(yxq.getDate()-row.alertDays);//有效期至-提醒天数
//                         console.log("当前时间："+date.toLocaleDateString());
//                         console.log("有效期提醒时间："+yxq.toLocaleDateString());
//                         console.log(yxq >= date);
                        //有效提醒时间>=当前时间
                        if(yxq >= date){
                            return {css:{"background-color": "#FFFFFF"}};
                        }else{
                            return {css:{"background-color": "#f0adad"}};
                        }
                    }
                },
                {
                    field: 'alertDays',
                    title: '预警天数'
                },
                {
                    field: 'zlwj',
                    title: '附件',
                    formatter: function(value, item, index) {
//                     	var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(item.zlwj));
                    	var url = item.zlwj;
    	        		return "<a target='_blank' href="+url+">"+item.zlwj+"</a>";
		            }
                },
                {
                    field: 'createUser',
                    title: '创建人'
                },
                {
                    field: 'createAt',
                    title: '创建时间',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>